package tech.xs.workflow.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import tech.xs.common.framework.domain.annotations.Dict;
import tech.xs.common.framework.domain.annotations.DictData;
import tech.xs.common.framework.domain.enums.BaseEnum;

import java.util.HashMap;
import java.util.Map;

@Dict(code = "BpmnNodeType", name = "BPMN节点类型")
public enum BpmnNodeTypeEnum implements BaseEnum {

    @DictData(name = "事件", order = 10)
    EVENT(0);

    @EnumValue
    @JsonValue
    private final int value;

    private static final Map<Integer, BpmnNodeTypeEnum> mappings = new HashMap<>(values().length);

    static {
        for (BpmnNodeTypeEnum item : values()) {
            mappings.put(item.getValue(), item);
        }
    }

    BpmnNodeTypeEnum(int value) {
        this.value = value;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static BpmnNodeTypeEnum create(int value) {
        return mappings.get(value);
    }

    @Override
    public Integer getValue() {
        return value;
    }
}
